<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">

<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<body class="easyui-layout">
<!-- 说明 字符串：Project，作为替换字符串 -->
<div class="easyui-layout" style="width:100%;height:100%;">
	<!-- 主表  -->
	<table id="project_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
		   data-options="rownumbers:true, pagination:true,singleSelect:true,url:'/share-list/1/20',
					  method:'get',
					  toolbar:'#tb',
					  loadMsg : '数据加载中',
					  onLoadSuccess:function(data){
                            $('.download').linkbutton({plain:true,iconCls:'icon-download'});
                        },
					  showFooter: true" >
        <thead>
            <tr>
                <th data-options="field:'id',width:150,align:'center' ,formatter:idFormatter">操作</th>
                <th data-options="field:'userId',width:100,align:'center' ,formatter:userIdFormatter">共享人员</th>
                <th data-options="field:'proId',width:150,align:'center' ">项目编号</th>
                <th data-options="field:'proName',width:200,align:'center' ">项目名称</th>
                <th data-options="field:'proState',width:100,align:'center' ,formatter:proStateFormatter ">项目状态</th>
                <th data-options="field:'proCategory',width:100,align:'center' ,formatter:proCategoryFormatter ">项目分类</th>
                <th data-options="field:'proCampanyid',width:200,align:'center' ,formatter:proCampanyidFormatter ">标的公司</th>
                <th data-options="field:'proLabel',width:200,align:'center'  ">项目标签</th>
            </tr>
        </thead>
	</table>
</div>


<!-- 搜索框 -->
<div id="tb" style="padding:5px;height:auto">
	<div>
        项目状态
        <input class="easyui-combobox" name="state"id="state"
               data-options="
				url : '/constants/proj_state',
				method: 'get',
				valueField:'key',
				textField:'value',
				">
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
	</div>
    <div style="margin:5px 0;"></div>
    <#include "/common/button.html">
</div>

<script type="text/javascript">
    $("#searchByParameter").click(function(){
        var state = $("#state").val();
        var handler = '/share-list/1/20?state='+state;
        $('#project_table').datagrid('options').url = handler;
        $('#project_table').datagrid('reload');
    });
</script>

<script type="text/javascript">
    function idFormatter(value,row) {
        var button ='';
            button += '<a href="#" class="download" title="打包下载" onclick=\'down('+value+')\'></a> ';
        return button;
    }
    function  proCategoryFormatter(val) {
        var result = '';
        $.ajax({
            url : '/constants/proj_category/'+val,
            async : false,
            success :function (data) {
                result = data;
            }
        })
        return result;
    }
    function proStateFormatter(val) {
        var result = '';
        $.ajax({
            url : '/constants/proj_state/'+val,
            async : false,
            success :function (data) {
                result = data;
            }
        })
        return result;
    }
    function userIdFormatter(val){
        var result = '';
        $.ajax({
            url : '/user-get/'+val,
            async : false,
            success :function (data) {
                result = data;
            }
        })
        return result;
    }
    function proCampanyidFormatter(val){
        var result = '';
        $.ajax({
            url : '/company-get/'+val,
            async : false,
            success :function (data) {
                result = data;
            }
        })
        return result;
    }
</script>

<!-- 按钮操作 -->
<script type="text/javascript">

    function down(val){
        window.location = "/project-zip/"+val;
    }
	$('#export').click(function(){
        window.location = "/project-download";
    });
</script>

<!-- 分页 -->
<script type="text/javascript">
	$(function(){
		var p = $('#project_table').datagrid().datagrid('getPager');
		p.pagination({
			pageSize: 20, //每页显示的记录条数，默认为10
			pageList: [20, 40, 60], //可以设置每页记录条数的列表
			onSelectPage: function (pageNumber, pageSize) {
			    if(pageNumber==0){
			        pageNumber = 1;
                }
				var handler = '/share-list/'+pageNumber+"/"+pageSize;
				$('#project_table').datagrid('options').url = handler;
				$('#project_table').datagrid('reload');
			}
		});
	})
</script>